<?php

class Bcms_Db_Form
{
	/**
	 * Instancia de la tabla a convertir
	 * 
	 * @var Bcms_Db_Table
	 */
	protected $_table;
	
	/**
	 * Campos del recurso
	 * 
	 * @var array
	 */
	protected $_fields;
	
	/**
	 * Configuracion de los elementos del formulario
	 * 
	 * @var Zend_Config
	 */
	protected $_formConfig;

	public function __construct($table, $config = array())
	{
		if( !$table instanceof Bcms_Db_Table ){
			throw new Bcms_Db_Exception('Invalid Bcms_Db_Table instance passed to form creator.');
		}

		$this->_table = $table;
	}

	protected function _setFields()
	{
		$this->_fields = $this->_table->info('metadata');
	}

	protected function _getFields()
	{
		return $this->_fields;
	}
	
	protected function _getFormConfig()
	{
		return $this->_formConfig;
	}
	
	public function toForm()
	{
		$form = new Zend_Form($this->_formConfig);

		return $form;
	}
}